/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package kimo.bl;

import captions.CaptionsEnum;
import java.util.Date;
import java.util.ResourceBundle;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Textbox;

/**
 *
 * @author a381u296
 */
public class zkUtils {

    private static final String captionsFileName = "captions.captions";
    private static final ResourceBundle rb = ResourceBundle.getBundle(captionsFileName);

    public static void myMessagebox(CaptionsEnum caption) {
        //Messagebox.show(rb.getString(CaptionsEnum.AFM_NOT_COMPLETED_APPLICATION.toString()));
        
        
        Messagebox.show(rb.getString(caption.toString()));
        
    }

   
    /** 
     *  Assigns String to a textbox only if it is not null
     *  or empty
     *
     * @param textbox  Textbox
     * @param string  String
     */
    
    public static void setTextboxValue(Textbox textbox, String string) {
       if (string != null) {
            if (!"".equals(string)) {
                textbox.setValue(string);
            }
       }
    }
    
    
    
    /**
     *  Assigns date to a Datebox only if its not null
     *
     * @param datebox
     * @param date
     */
    public static void setDateboxValue(Datebox datebox, Date date) {
        if (date != null) {
            datebox.setValue(date);
        }
    }
    
}
